from common.base_page import BasePage
from configs.config import Config
from po.main_page import MainPage


class LoginPage(BasePage):
    def open_login_page(self, url=Config.URL):
        self.open_url(url)
        return self  # 返回对象本身，方便链式调用

    def login(self, username, password):
        self.input_text(locator=self['username'], text=username)
        self.input_text(locator=self['password'], text=password)
        self.click_element(locator=self['login_button'])
        return MainPage()  # 返回MainPage对象，即首页，供链式调用
